package com.smartEdu.controller.web;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.smartEdu.websocket.WebsocketEndPoint;

@Controller
public class SweepQr{
	
	@RequestMapping(value="sweepQr")
	public void sweeQr(HttpServletRequest request,HttpServletResponse response) throws Exception{
			String key=request.getParameter("key");
			System.err.println(key);
			//String email=ServletActionContext.getRequest().getParameter("email");
			//String passwd=ServletActionContext.getRequest().getParameter("passwd");
			if (WebsocketEndPoint.cowa.containsKey(key)) {
				WebsocketEndPoint websocketEndPoint=WebsocketEndPoint.cowa.get(key);
				String resp="{\"flag\":1}";
				websocketEndPoint.sendmessage(resp);
				response.getOutputStream().write(resp.getBytes());
				response.getOutputStream().close();
			}
	}
}
